package floappcontest.core.beans;

/**
 * It represents a Floapp Contest session bound to an user.
 */
public class FloappSession {

	private static User user;

	private static UserType type;


	/**
	 * It binds a new user to this Floapp Contest session.
	 * 
	 * @param newUser
	 *            The new current user.
	 * @param newType
	 *            The type of the current user.
	 */
	public static void bind( User newUser, UserType newType ) {
		FloappSession.user = newUser;
		FloappSession.type = newType;
	}


	/**
	 * It verigies of there is an user associated to this session.
	 * 
	 * @return <code>true<code> if there is an user bound to this session; otherwise it returns <code>false<code>.
	 */
	public static boolean isBound() {
		return FloappSession.user != null && FloappSession.type != null;
	}


	/**
	 * It unbinds the curernt user from this Floapp Contest Session.
	 */
	public static void unbind() {
		FloappSession.user = null;
		FloappSession.type = null;
	}


	/**
	 * Observer method for attribute user
	 * 
	 * @return The user bound to this session;
	 */
	public static User getUser() {
		return user;
	}


	/**
	 * Observer method for attribute type
	 * 
	 * @return The type of the user bound to this session;
	 */
	public static UserType getType() {
		return type;
	}
}